1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module soup.AuthDomainDigest;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import soup.AuthDomain;
32 private import soup.c.functions;
33 public  import soup.c.types;
34 
35 
36 /** */
37 public class AuthDomainDigest : AuthDomain
38 {
39 	/** the main Gtk struct */
40 	protected SoupAuthDomainDigest* soupAuthDomainDigest;
41 
42 	/** Get the main Gtk struct */
43 	public SoupAuthDomainDigest* getAuthDomainDigestStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return soupAuthDomainDigest;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected override void* getStruct()
52 	{
53 		return cast(void*)soupAuthDomainDigest;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (SoupAuthDomainDigest* soupAuthDomainDigest, bool ownedRef = false)
60 	{
61 		this.soupAuthDomainDigest = soupAuthDomainDigest;
62 		super(cast(SoupAuthDomain*)soupAuthDomainDigest, ownedRef);
63 	}
64 
65 
66 	/** */
67 	public static GType getType()
68 	{
69 		return soup_auth_domain_digest_get_type();
70 	}
71 
72 	/**
73 	 * Encodes the username/realm/password triplet for Digest
74 	 * authentication. (That is, it returns a stringified MD5 hash of
75 	 * @username, @realm, and @password concatenated together). This is
76 	 * the form that is needed as the return value of
77 	 * #SoupAuthDomainDigest's auth handler.
78 	 *
79 	 * For security reasons, you should store the encoded hash, rather
80 	 * than storing the cleartext password itself and calling this method
81 	 * only when you need to verify it. This way, if your server is
82 	 * compromised, the attackers will not gain access to cleartext
83 	 * passwords which might also be usable at other sites. (Note also
84 	 * that the encoded password returned by this method is identical to
85 	 * the encoded password stored in an Apache .htdigest file.)
86 	 *
87 	 * Params:
88 	 *     username = a username
89 	 *     realm = an auth realm name
90 	 *     password = the password for @username in @realm
91 	 *
92 	 * Returns: the encoded password
93 	 */
94 	public static string encodePassword(string username, string realm, string password)
95 	{
96 		auto retStr = soup_auth_domain_digest_encode_password(Str.toStringz(username), Str.toStringz(realm), Str.toStringz(password));
97 
98 		scope(exit) Str.freeString(retStr);
99 		return Str.toString(retStr);
100 	}
101 
102 	/**
103 	 * Sets the callback that @domain will use to authenticate incoming
104 	 * requests. For each request containing authorization, @domain will
105 	 * invoke the callback, and then either accept or reject the request
106 	 * based on @callback's return value.
107 	 *
108 	 * You can also set the auth callback by setting the
109 	 * %SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK and
110 	 * %SOUP_AUTH_DOMAIN_DIGEST_AUTH_DATA properties, which can also be
111 	 * used to set the callback at construct time.
112 	 *
113 	 * Params:
114 	 *     callback = the callback
115 	 *     userData = data to pass to @auth_callback
116 	 *     dnotify = destroy notifier to free @user_data when @domain
117 	 *         is destroyed
118 	 */
119 	public void setAuthCallback(SoupAuthDomainDigestAuthCallback callback, void* userData, GDestroyNotify dnotify)
120 	{
121 		soup_auth_domain_digest_set_auth_callback(cast(SoupAuthDomain*)soupAuthDomainDigest, callback, userData, dnotify);
122 	}
123 }